#!/bin/bash

# 开启指定数量的机器人
h="./client.sh start|kill [机器人数量]"

op=$1

# 单客户端机器人数量
oneNum=300

case $op in
	start)
		robotNum=$2
		clientNum=$((robotNum/oneNum))
		if [ $((robotNum%oneNum)) != 0 ]; then
			clientNum=$((clientNum+1))
		fi
		if [ $clientNum == 0 ]; then
			clientNum=1
		fi
		for ((i=1;i<=$clientNum;i++)); do
			nohup ./$i/client.out > /dev/null 2>&1 &
		done
		echo "start client num:$clientNum"
		;;
	stop)
		pkill client.out
		echo "stop client"
		;;
	*)
		echo $h
		;;
esac

